package com.vhall.component.entity.pendant.vo;

import com.alibaba.fastjson.annotation.JSONField;
import com.vhall.component.framework.common.annotation.ParamName;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

/**
 * @author guoxin.wang
 * @date 2021-10-29 11:19
 */
@Data
public class PendantDeleteReqVO implements Serializable {

    private static final long serialVersionUID = 5316139049894805618L;

    /**
     * 挂件id，多个用逗号相隔
     */
    @NotBlank(message = "ids参数不允许为空")
    @ParamName("ids")
    @Pattern(regexp = "^(?!,)[\\d,]*(?<!,)$", message = "ids参数错误，请传入正确的格式")
    private String ids;

    /**
     * 获取ids
     *
     * @return 商品ids
     */
    @JSONField(serialize = false)
    public Set<String> getIds() {
        String[] arr = ids.split(",");
        return new HashSet<>(Arrays.asList(arr));
    }

}
